/*
 * Image.h
 *
 *  Created on: Jul 7, 2009
 *      Author: kurt
 */

#ifndef IMAGE_H_
#define IMAGE_H_

#include "Resizable2DInterface.h"
#include <GL/gl.h>

namespace objdraw 
{

class Image: public objdraw::Resizable2DInterface 
{
	public:
		typedef struct ImageData
		{
			GLuint texid;
			int width;
			int height;
			int textureWidth;// the real width of data, 2^n with n>=0
			int textureHeight; // the real height of data, 2^n with n>=0
			int bpp;
			unsigned int * data;
			unsigned int size;
		} __ImageData;
	protected:
		virtual ~Image();
		std::string error;
		bool mirroredVert, mirroredHori;
	private:
		Image(Image const & r);
	public:
		ImageData data;
		
//		Image();
		Image(DrawingCanvas * c = NULL);
		
		virtual void render();
		
		uint getPixel(uint x, uint y);
		void setPixel(uint x, uint y, uint pixel);
		
		uint getImageWidth();
		uint getImageHeigth();
		
		GLuint & getTexId();
		
		bool isMirroredVert();
		bool isMirroredHori();
		void mirrorVert();
		void mirrorHori();
		void setVertMirror(bool mir);
		void setHoriMirror(bool mir);
//		TODO virtual std::string toString();
		friend class ImageUtil;
};

}

#endif /* IMAGE_H_ */
